package auctionhaus



import grails.test.mixin.*
import org.junit.*

/**
 * See the API for {@link grails.test.mixin.services.ServiceUnitTestMixin} for usage instructions
 */
@TestFor(ListingService)
@Mock([Customer, Listing, CustomerService])
class ListingServiceTests {
    def listingService
    def customerService
    def seller
    
    public void setUp() {
        listingService = new ListingService()
        customerService = new CustomerService()
        seller = customerService.addCustomer("johndoe@acme.com", "asdfqw")
    }

    void testAddListing() {
        def listingInstance = listingService.addListing("new listing", "description", new Date()+1, seller, 3)
        assert listingInstance.id > 0
    }
    
    void testInvalidListing() {
        def listingInstance = listingService.addListing("new listing", "description", new Date()-1, null, -1)
        assert listingInstance.hasErrors()
    }
    
    public void tearDown() {
        listingService = null
        customerService = null
        seller = null
    }
}
